home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Review 28
/
Creative-Review-CD-ROM-28.iso
/
pc
/
kungfu
/
assets
/
game.dir
/
00035_Script_actor class
< prev
next >
Wrap
Text File
|
1997-08-08
|
7KB
|
290 lines
-- actor class method
-- --------------------------------------------------
-- abstract superclass for baddy and player for v2.0b
-- --------------------------------------------------
property data
property type
property ancestor
property health
property cell
property direction
property nextmove
property nextmoveflag
property currentmove
-- --------------------------------------------------
global gcell
global gblocks
global gstar
global gsound
global gkeytomove
-- ==================================================
-- new method
-- --------------------------------------------------
on new me, props
minit me, props
return me
end mnew
-- ==================================================
-- minit method
-- --------------------------------------------------
on minit me, props
-- put "in minit actor"
set blockflag = false
set data = checkaprop ( props, #data, #loony )
set health = checkaprop ( props, #health, 0 )
set type = checkaprop ( props, #type, #loony )
set direction = checkaprop ( props, #direction, #left )
set cell = checkaprop ( props, #cell, #nocell )
set ancestor = new ( script "anim manager class" , props )
-- put "out minit actor"
end minit
-- ==================================================
-- mdispose me
-- --------------------------------------------------
on mdispose me
-- put "in mdispose actor class"
mdispose ancestor
set ancestor = 0
-- put "in mdispose actor class"
end mdispose me
-- ==================================================
-- mmovefinish method
-- --------------------------------------------------
on mmovefinish me
-- put "in mmovefinish actor"
set pixeloffset = 0
case currentmove of
#walkleft:
mfinishwalk gcell, me, cell, #left
set move = - 1
#walkright:
mfinishwalk gcell, me, cell, #right
set move = 1
#jumpleft:
set move = - 8
#jumpright:
set move = + 8
end case
set cell = cell + move
set theloch = ( mcell2screen ( gcell, the cell of me ) )
set theloc = point ( theloch, mgetfloor ( gcell ) )
set offset = ( mgetstartoffset ( gcell, the direction of me , data ) )
set theloc = theloc + offset
msetloc ( me, theloc )
-- put "out mmovefinish actor"
end mmovefinish me
-- ==================================================
-- msetcurrentmove method
-- --------------------------------------------------
on msetcurrentmove me, themove
-- put "in msetcurrentmove"
case themove of:
#jumpleft: mjump gcell me, cell, #left
#jumpright: mjump gcell me, cell, #right
#turnleft: set direction = #left
#turnright: set direction = #right
#walkleft: mstartwalk gcell, me, cell, #left
#walkright: mstartwalk gcell, me, cell, #right
end case
set currentmove = themove
-- put "repeatindex: " , repeatindex
-- put "currentmove: " , currentmove
-- put "currentrepeatflag: " , currentrepeatflag
msetanim ancestor, currentmove, me
-- put "out msetcurrentmove"
end msetcurrentmove
-- ==================================================
-- mhit method
-- --------------------------------------------------
on mhit me, starloc
-- put "in mhit actor" , me
set others = mcheck ( gcell, cell, direction )
if count ( others ) then
set other = getat ( others, 1 )
if mhurt ( other, currentmove ) then
mslap gsound, data
mstart gstar, the data of other, ( the loc of me + starloc )
return true
end if
end if
return false
put "out mhit actor"
end mhit
-- ==================================================
-- mcheckblock method
-- --------------------------------------------------
on mcheckblock me, attackmove
set myblocks = getaprop ( gblocks, type )
set validblocks = getaprop ( myblocks , attackmove )
if not ( listp ( validblocks ) ) then return false
if getone ( validblocks, currentmove ) then return true
else return false
end mcheckblock
-- ==================================================
-- mcheckhurt method
-- --------------------------------------------------
on mcheckhurt me, attackmove, starloc,
-- put "in mhurt actor", health, damage
if not ( mcheckblock ( me, attackmove ) ) then
mdamage me, 10
return true
end if
return false
-- put "nextmove: " , nextmove
-- put "out mhurt actor" , health
end mcheckhurt
-- ==================================================
-- mkeytomove method
-- --------------------------------------------------
on mkeytomove me, thekey
set anims = getaprop ( gkeytomove, direction)
set themove = getaprop ( anims, thekey )
return themove
end mkeytomove
-- ==================================================
-- mgetcurrentkey method
-- --------------------------------------------------
on mgetcurrentkey me
return mmovetokey ( me, currentmove )
end mgetcurrentkey
-- ==================================================
-- mmovetokey method
-- --------------------------------------------------
on mmovetokey me, move
set movelist = getaprop ( gkeytomove, direction )
set key = getone ( movelist, move)
return key
end mmovetokey
-- ==================================================
-- mcheckwalk method
-- --------------------------------------------------
on mcheckwalk me, newmove
case newmove of
#walkleft:
set who = mcheck ( gcell, cell , #left )
if not ( count ( who ) = 0 ) then set newmove = #idleleft
#walkright:
set who = mcheck ( gcell, cell, #right )
if not ( count ( who ) = 0 ) then set newmove = #idleright
end case
return newmove
end mcheckwalk
-- ==================================================
-- mdamage method
-- --------------------------------------------------
on mdamage me, thedamage
set health = health - thedamage
if health <= 0 then
set nextkey = #die
mstartdie me
else set nextkey = #hit
mabort me
msetcurrentmove me, mkeytomove ( me , nextkey )
end mdamage
-- ==================================================
-- mstartdie method
-- --------------------------------------------------
on mstartdie me
-- put "in mstartdie actor"
-- put "out mstartdie actor"
end mstartdie
-- ==================================================
-- mabort method
-- --------------------------------------------------
on mabort me
-- put "in mabort actor class :"
set nextmoveflag = false
mmovefinish me
mabort ancestor
-- put "out mabort actor class :"
end mabort